package com.example.mydemo2;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Context;
import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class BusinessListRecycleActivity extends AppCompatActivity {
    private Context context;
    private List<BusinessItem> businessList = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_business_list_recycle);
        //1找到指定的显示控件
        RecyclerView businessListView = findViewById(R.id.business_list_view);
        context = this;
        //2指定布局形式
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        businessListView.setLayoutManager(linearLayoutManager);
        //3自定义适配器
        BusinessRecycleAdapter businessRecycleAdapter = new BusinessRecycleAdapter();
        businessListView.setAdapter(businessRecycleAdapter);

        //4设置数据
        initData();
        businessRecycleAdapter.setData(businessList);

    }
    public void initData(){

       BusinessItem businessItem = new BusinessItem();
        businessItem.setBusinessImage(R.drawable.car1);
        businessItem.setTvBusinessNick("无忧回收者");
        businessItem.setTvBusinessDistance("00km");
        businessItem.setTvBusinessState("离开");
        businessList.add(businessItem);

        BusinessItem businessItem1 = new BusinessItem();
        businessItem1.setBusinessImage(R.drawable.car2);
        businessItem1.setTvBusinessNick("易大师的杀猪刀");
        businessItem1.setTvBusinessDistance("10km");
        businessItem1.setTvBusinessState("在线");
        businessList.add(businessItem1);

        BusinessItem businessItem2 = new BusinessItem();
        businessItem2.setBusinessImage(R.drawable.car2);
        businessItem2.setTvBusinessNick("易大师的杀猪刀2");
        businessItem2.setTvBusinessDistance("102km");
        businessItem2.setTvBusinessState("在线");
        businessList.add(businessItem2);


        BusinessItem businessItem3 = new BusinessItem();
        businessItem3.setBusinessImage(R.drawable.car1);
        businessItem3.setTvBusinessNick("无忧回收者");
        businessItem3.setTvBusinessDistance("00km");
        businessItem3.setTvBusinessState("离开");
        businessList.add(businessItem3);

        BusinessItem businessItem4 = new BusinessItem();
        businessItem4.setBusinessImage(R.drawable.car1);
        businessItem4.setTvBusinessNick("无忧回收者");
        businessItem4.setTvBusinessDistance("00km");
        businessItem4.setTvBusinessState("离开");
        businessList.add(businessItem4);

        BusinessItem businessItem5 = new BusinessItem();
        businessItem5.setBusinessImage(R.drawable.car1);
        businessItem5.setTvBusinessNick("无忧回收者");
        businessItem5.setTvBusinessDistance("00km");
        businessItem5.setTvBusinessState("离开");
        businessList.add(businessItem5);


    }



}